home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / editors / mutt / me2s_pl7.zoo / mu_edit2 / util / savestr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-05  |  610 b   |  24 lines

  1. static char rcsid[] = "$Id: savestr.c,v 1.1 1992/09/06 19:31:32 mike Exp $";
  2.  
  3. /* $Log: savestr.c,v $
  4.  * Revision 1.1  1992/09/06  19:31:32  mike
  5.  * Initial revision
  6.  *
  7.  */
  8.  
  9. /* savestr.c:  Save a string by malloc()ing space and coping the string.
  10.  * Returns a pointer to the malloc()ed string.
  11.  * This is a "black box" copy of a routine in Microsoft C.
  12.  * C Durland    Public Domain
  13.  */
  14.  
  15. #include "const.h"
  16.  
  17. char *savestr(str) char *str;    /* malloc str and save it */
  18. {
  19.   char *ptr, *malloc(), *strcpy();
  20.  
  21.   if ((ptr = malloc(strlen(str)+1)) == NULL) return NULL;
  22.   return strcpy(ptr,str);
  23. }
  24.